﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<link rel="stylesheet" type="text/css" media="screen" href="css/jquery-ui-1.8.1.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-cn.js" type="text/javascript"></script>
<script src="js/json2.js" type="text/javascript"></script>
<script type="text/javascript">
	$.jgrid.no_legacy_api = true;
	$.jgrid.useJSON = true;
</script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script type="text/javascript">
function districtAlloc(dist) {
	$.get("main",{action:"15",oper:"alloc",district:dist},function (data, textStatus) {
		if (data.code == 0) {
			alert("下拨资金操作成功!");
			jQuery("#list1").jqGrid().trigger('reloadGrid');
		}
	});
};

function allocState(cellvalue, options, rowObject) {
	district = rowObject[1];
	
	if (cellvalue == "1")
		return "<img src='images/greenball.gif' title='已下拨' />";
	
	if (cellvalue == "0")
		return "<input type='button' value='下拨' onClick='districtAlloc(" + district + ")' />";
};

function toExcel() {
	$("#df").attr("src","main?action=19&oper=excel");
};

function setGrid() {
	jQuery("#list1").jqGrid({ 
			url:'main?action=19',
			hidegrid: "false",
			datatype: "json",
			colNames: ['年月','所属县区','视力残疾人数','视力残疾需要发放资金','听力残疾人数','听力残疾需要发放资金','言语残疾人数','言语残疾发放资金','肢体残疾人数','肢体残疾发放资金','智力残疾人数','智力残疾发放资金','精神残疾人数','精神残疾发放资金','多重残疾人数','多重残疾发放资金','人员合计','发放资金合计'],
			colModel: [
				{name:'month',width:80, align:'right', sortable:false},
				{name:'district',width:70, align:'right',sortable:false, formatter:'select', editoptions:{value:"1:市辖区;2:桥东区;3:桥西区;4:高新区;5:宣化区;6:下花园区"}},
				{name:'shili',width:80, sortable:false, align:'right'},
				{name:'shili1',width:120, sortable:false, align:'right'},
				{name:'tingli',width:80, sortable:false, align:'right'},
				{name:'tingli1',width:120, sortable:false, align:'right'},
				{name:'yanyu',width:80, sortable:false, align:'right'},
				{name:'yanyu1',width:120, sortable:false, align:'right'},
				{name:'zhiti',width:80, sortable:false, align:'right'},
				{name:'zhiti',width:120, sortable:false, align:'right'},
				{name:'zhili',width:80, sortable:false, align:'right'},
				{name:'zhili1',width:120, sortable:false, align:'right'},
				{name:'jingshen',width:80, sortable:false, align:'right'},
				{name:'jingshen',width:120, sortable:false, align:'right'},
				{name:'duochong',width:80, sortable:false, align:'right'},
				{name:'duochong1',width:120, sortable:false, align:'right'},
				{name:'totalnum',width:80, align:'right',sortable:false},
				{name:'totalmoney',width:120, align:'right',sortable:false}
			],
			viewrecords: true,
			subGrid: true,
			height: 300,
			shrinkToFit: false,
			caption:"本县区资金下拨历史信息",
			subGridRowExpanded: function(subgrid_id, row_id) {
				var subgrid_table_id, pager_id;
				subgrid_table_id = subgrid_id+"_t";
				subgridid = subgrid_table_id;
				
				$("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table>");
				jQuery("#"+subgrid_table_id).jqGrid({
					url:"main?action=25&oper=sub&id="+row_id,
					datatype: "json",
					colNames: ['街道办事处','视力残疾人数','视力残疾需要发放资金','听力残疾人数','听力残疾需要发放资金','言语残疾人数','言语残疾发放资金','肢体残疾人数','肢体残疾发放资金','智力残疾人数','智力残疾发放资金','精神残疾人数','精神残疾发放资金','多重残疾人数','多重残疾发放资金','人员合计','发放资金合计'],
					colModel: [
						{name:'street',width:150, sortable:false, align:'right'},
						{name:'shili',width:80, sortable:false, align:'right'},
						{name:'shili1',width:120, sortable:false, align:'right'},
						{name:'tingli',width:80, sortable:false, align:'right'},
						{name:'tingli1',width:120, sortable:false, align:'right'},
						{name:'yanyu',width:80, sortable:false, align:'right'},
						{name:'yanyu1',width:120, sortable:false, align:'right'},
						{name:'zhiti',width:80, sortable:false, align:'right'},
						{name:'zhiti',width:120, sortable:false, align:'right'},
						{name:'zhili',width:80, sortable:false, align:'right'},
						{name:'zhili1',width:120, sortable:false, align:'right'},
						{name:'jingshen',width:80, sortable:false, align:'right'},
						{name:'jingshen',width:120, sortable:false, align:'right'},
						{name:'duochong',width:80, sortable:false, align:'right'},
						{name:'duochong1',width:120, sortable:false, align:'right'},
						{name:'totalnum',width:80, sortable:false, align:'right'},
						{name:'totalmoney',width:120, sortable:false, align:'right'}
					],
					rowNum:7,
					height: '100%'
				});
			},
			subGridRowColapsed: function(subgrid_id, row_id) {
				// this function is called before removing the data
				var subgrid_table_id;
				subgrid_table_id = subgrid_id+"_t";
				jQuery("#"+subgrid_table_id).remove();
			}
	});
	
	jQuery("#list2").jqGrid({ 
			url:'main?action=25',
			hidegrid: "false",
			datatype: "json",
			colNames:['街道办事处','视力残疾人数','视力残疾需要发放资金','听力残疾人数','听力残疾需要发放资金','言语残疾人数','言语残疾发放资金','肢体残疾人数','肢体残疾发放资金','智力残疾人数','智力残疾发放资金','精神残疾人数','精神残疾发放资金','多重残疾人数','多重残疾发放资金','合计人数','合计需发放资金'], 
			colModel:[ 
					{name:'street',width:170, sortable:false, align:'right'},
					{name:'shili',width:80, sortable:false, align:'right'},
					{name:'shili1',width:120, sortable:false, align:'right'},
					{name:'tingli',width:80, sortable:false, align:'right'},
					{name:'tingli1',width:120, sortable:false, align:'right'},
					{name:'yanyu',width:80, sortable:false, align:'right'},
					{name:'yanyu1',width:120, sortable:false, align:'right'},
					{name:'zhiti',width:80, sortable:false, align:'right'},
					{name:'zhiti',width:120, sortable:false, align:'right'},
					{name:'zhili',width:80, sortable:false, align:'right'},
					{name:'zhili1',width:120, sortable:false, align:'right'},
					{name:'jingshen',width:80, sortable:false, align:'right'},
					{name:'jingshen',width:120, sortable:false, align:'right'},
					{name:'duochong',width:80, sortable:false, align:'right'},
					{name:'duochong1',width:120, sortable:false, align:'right'},
					{name:'totalNum',width:80, sortable:false, align:'right'},
					{name:'totalMoney',width:120, sortable:false, align:'right'}
			],
			height: 180,
			editurl:'main?action=25',
			caption:"三无/低保/高龄人员统计信息"
	})};  
	
	$(document).ready(function(){
		setGrid();
		$("#adddata").click(function(){
			jQuery("#list2").jqGrid('delGridRow', "0", {
			  				caption:"确定要下拨资金吗？", 
			  				msg:"将要下拨给本区的资金列于上表中",
			  				bSubmit:"确定",
			  				delicon: [true,'left','ui-icon-play'],
			  				top: 200,
				  			left: 400,
			  				modal: true,
			  				closeAfterEdit:true,
			  				afterSubmit : function(r, postdata) {
			  					var data = eval('(' + r.responseText + ')');
			  					switch (data.code) {
			  						case 0: alert("本月资金下拨成功！"); jQuery("#list1").jqGrid().trigger('reloadGrid'); return [true, ""];
			  						case 1000: return [false, "本月度资金下拨正在进行中，请在下拨信息中查看！"];
			  						case 1001: return [false, "非下拨月，请于每季度首月进行下拨操作！"];
			  						case 20000: return [false, "操作失败，该月度资金已经下拨，请勿重复！"];
			  						case 23505: return [false, "操作失败，该月度资金已经下拨，请勿重复！"];
			  						default: return [false, data.message];
			  					}
			  				}
			});
		});
		$("#resetdata").click(function(){
			jQuery("#list2").jqGrid('delGridRow', "0", {
			  				caption: "确定要将所有账户清零吗？", 
			  				msg: "所有账户金额都将被清零，不可恢复",
			  				url: 'main?action=26',
			  				bSubmit: "确定",
			  				delicon: [true,'left','ui-icon-play'],
			  				top: 200,
				  			left: 400,
			  				modal: true,
			  				closeAfterEdit:true,
			  				afterSubmit : function(r, postdata) {
			  					var data = eval('(' + r.responseText + ')');
			  					switch (data.code) {
			  						case 0: alert("所有账户均已清零！"); return [true, ""];
			  						case 1001: return [false, "非清零月，请于每季度首月进行清零操作！"];
			  						default: return [false, data.message];
			  					}
			  				}
			});
		});
		$("#sf_excel").click(toExcel);
	});
</script>
<body style="background-color:#d9f1cc;">
				<iframe id="df"  name="df" src="" width=0 height=0 frameborder="0" ></iframe>
				<input type="button" id="sf_excel" value="导 出">
				<div id="RightPane"  >
					<div class="innertube">
					<table id="list1"></table>
					<p />
					<table id="list2"></table>
					<p />
					<input type="button" id="adddata" value="下拨资金"><input type="button" id="resetdata" value="账户清零">
				</div>
				</div>
</body>
